<include file="public@header"/>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>{:lang('FOWL_USER_LIST')}</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="">
        关键字:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$keyword|default=''}" placeholder="请输入关键字...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('AdminOauth/index')}">清空</a>
        <div style="float:right;" class="form-group">
            <a href="{:url('adminOauth/updateAll')}" class="btn btn-success js-ajax-update-all" data-msg="">更新用户信息</a>
        </div>
    </form>
    <form method="post" class="js-ajax-form margin-top-20">
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>ID</th>
                <th>{:lang('STAFF_NUMBER')}</th>
                <th>{:lang('USERNAME')}</th>
                <th>照片</th>
                <th>部门</th>
                <th>{:lang('STAFF_GRADE')}</th>
                <th>{:lang('INTEGRAL')}</th>
                <th>{:lang('LEARN_TIME')}</th>
                <th>{:lang('VEDIO_SCORE')}（平均）</th>
                <th>{:lang('SPECTATOR')}</th>
                <th>{:lang('FOCUS')}</th>
                <th>{:lang('FANS')}</th>
                <th>{:lang('LAST_LOGIN_TIME')}</th>
                <th>{:lang('STATUS')}</th>
                <th align="center">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="lists" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.staff_number}</td>
                    <td>{$vo.staff_name}</td>
                    <td>
                        <a href="javascript:parent.imagePreviewDialog('<?php echo STAFF_SERVER.$vo['staff_pic'];?>');">
                        <notempty name="vo.staff_pic">
                            <img height="50" src="<?php echo STAFF_SERVER.$vo['staff_pic'];?>"/>
                        </notempty>
                        </a>
                    </td>
                    <td>{$vo.staff_deptname}</td>
                    <td>{$vo.staff_duty}</td>
                    <td>{$vo.integral}</td>
                    <td>{$vo.learn_time}</td>
                    <td>{$vo.vedio_score}</td>
                    <td>{$vo.spectator}</td>
                    <td>{$vo.focus_amount}</td>
                    <td>{$vo.fans_amount}</td>
                    <td>{$vo.login_time}</td>
                    <td>
                        <if condition="$vo['status'] eq 1">{:lang('USER_STATUS_ACTIVATED')}<else />{:lang('USER_STATUS_BLOCKED')}</if>
                    </td>
                    <td>
                        <if condition="$vo['status'] eq 1">
                            <a href="{:url('adminOauth/update',array('id'=>$vo['id'],'status'=>$vo['status']))}" class="js-ajax-update">{:lang('USER_STATUS_BLOCKED')}</a>
                        <else />
                            <a href="{:url('adminOauth/update',array('id'=>$vo['id'],'status'=>$vo['status']))}" class="js-ajax-update">{:lang('ACTIVATE_USER')}</a>
                        </if>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <ul class="pagination">{$page}<li class="page item"><a class="page link" href="#">总数：{$count}条</a></li></ul>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>

// 启用、禁用
$('.js-ajax-update').on('click', function (e) {
    e.preventDefault();
    var $_this  = this,
        $this   = $($_this),
        href    = $this.data('href'),
        refresh = $this.data('refresh'),
        msg     = $this.data('msg');
    href        = href ? href : $this.attr('href');

    art.dialog({
        title: false,
        icon: 'question',
        content: msg ? msg : '确定要改变用户状态？',
        follow: $_this,
        close: function () {
            $_this.focus(); //关闭时让触发弹窗的元素获取焦点
            return true;
        },
        okVal: "确定",
        ok: function () {
            $.getJSON(href).done(function (data) {

                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        // animation: {
                        //     open: 'animated bounceInDown', // Animate.css class names
                        //     close: 'animated bounceOutUp', // Animate.css class names
                        // },
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (refresh == undefined || refresh) {
                                    if (data.url) {
                                        //返回带跳转地址
                                        // window.location.href = data.url;
                                        history.go(0) // 当前页面刷新
                                    } else {
                                        //刷新当前页
                                        reloadPage(window);
                                    }
                                }
                            }
                        }
                    }).show();

                } else if (data.code == '0') {
                    //art.dialog.alert(data.info);
                    //alert(data.info);//暂时处理方案
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            });
        },
        cancelVal: '关闭',
        cancel: true
    });
});

// 更新所有用户信息
$('.js-ajax-update-all').on('click', function (e) {
    e.preventDefault();
    var $_this  = this,
        $this   = $($_this),
        href    = $this.data('href'),
        refresh = $this.data('refresh'),
        msg     = $this.data('msg');
    href        = href ? href : $this.attr('href');

    art.dialog({
        title: false,
        icon: 'question',
        content: msg ? msg : '立即更新用户信息？',
        follow: $_this,
        close: function () {
            $_this.focus(); //关闭时让触发弹窗的元素获取焦点
            return true;
        },
        okVal: "更新",
        ok: function () {
            art.dialog({   
                title: '数据加载中,请稍后...  '  
            });
            $.get(href).done(function (data) {
                if (data.code == '1') {
                    noty({
                        text: data.msg,
                        type: 'success',
                        layout: 'topCenter',
                        modal: true,
                        // animation: {
                        //     open: 'animated bounceInDown', // Animate.css class names
                        //     close: 'animated bounceOutUp', // Animate.css class names
                        // },
                        timeout: 800,
                        callback: {
                            afterClose: function () {
                                if (refresh == undefined || refresh) {
                                    if (data.url) {
                                        //返回带跳转地址
                                        window.location.href = data.url;
                                        // history.go(0) // 当前页面刷新
                                    } else {
                                        //刷新当前页
                                        reloadPage(window);
                                    }
                                }
                            }
                        }
                    }).show();

                } else if (data.code == '0') {
                    //art.dialog.alert(data.info);
                    //alert(data.info);//暂时处理方案
                    art.dialog({
                        content: data.msg,
                        icon: 'warning',
                        ok: function () {
                            this.title(data.msg);
                            return true;
                        }
                    });
                }
            });
        },
        cancelVal: '算了',
        cancel: true
    });
});
    
</script>
</body>
</html>